﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Caching;
using System.Runtime.Serialization.Formatters.Binary;
using System.ServiceModel.Syndication;
using System.Web.UI;
using System.Xml;
using OpenWaves.Caching;
using OpenWaves.Syndication;
using System.Linq;

namespace OpenWaves.Web.Tests
{
    public partial class SyndicationTests : Page
    {
        protected IEnumerable<SyndicationItem> Feed;

        protected SyndicationTests()
        {
        }

        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            var aggregatedFeed = ServiceLocator.Resolve<IFeedAggregationService>().GetAggregatedFeed(this.feedsSelector
                .GetSelectedItems()
                .Select(i => Url.Parse(i.Value)));

            this.Feed = aggregatedFeed.Items.OrderByDescending(i=>i.PublishDate).Take(20);            
        }

        protected void feedSelector_SelectionChanged(object sender, EventArgs e)
        {
            this.DataBind();
        }
    }
}